// license-header java merge-point
/**
 * This is only generated once! It will never be overwritten.
 * You can (and have to!) safely modify it by hand.
 */
package com.jrsystems.jrbase.role;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

/**
 * @see com.jrsystems.jrbase.role.Role
 */
public class RoleDaoImpl
    extends com.jrsystems.jrbase.role.RoleDaoBase
{
    /**
     * @see com.jrsystems.jrbase.role.RoleDao#findByCriteria(com.jrsystems.jrbase.role.vo.RoleSearchCriteria)
     */
    protected com.jrsystems.jrbase.role.vo.RoleVO handleFindByCriteria(com.jrsystems.jrbase.role.vo.RoleSearchCriteria searchCriteria)
    {
    	Criteria criteria = getSession().createCriteria(Role.class);
    	
    	if(searchCriteria.getRole() != null){
    		criteria.add(Restrictions.ilike("role", "%"+searchCriteria.getRole()+"%"));
    	}
    	
    	if(searchCriteria.getRoleCode() != null){
    		criteria.add(Restrictions.like("roleCode", "%"+searchCriteria.getRoleCode()+"%"));
    	}
    	
    	if(searchCriteria.getRoleDescription() != null){
    		criteria.add(Restrictions.like("roleDescription", "%"+searchCriteria.getRoleDescription()+"%"));
    	}
        // @todo implement public com.jrsystems.jrbase.role.vo.RoleVO handleFindByCriteria(com.jrsystems.jrbase.role.vo.RoleSearchCriteria searchCriteria)
        return null;
}

    /**
     * @see com.jrsystems.jrbase.role.RoleDao#toRoleVO(com.jrsystems.jrbase.role.Role, com.jrsystems.jrbase.role.vo.RoleVO)
     */
    public void toRoleVO(
        com.jrsystems.jrbase.role.Role source,
        com.jrsystems.jrbase.role.vo.RoleVO target)
    {
        // @todo verify behavior of toRoleVO
        super.toRoleVO(source, target);
    }


    /**
     * @see com.jrsystems.jrbase.role.RoleDao#toRoleVO(com.jrsystems.jrbase.role.Role)
     */
    public com.jrsystems.jrbase.role.vo.RoleVO toRoleVO(final com.jrsystems.jrbase.role.Role entity)
    {
        // @todo verify behavior of toRoleVO
        return super.toRoleVO(entity);
    }


    /**
     * Retrieves the entity object that is associated with the specified value object
     * from the object store. If no such entity object exists in the object store,
     * a new, blank entity is created
     */
    private com.jrsystems.jrbase.role.Role loadRoleFromRoleVO(com.jrsystems.jrbase.role.vo.RoleVO roleVO)
    {
        // @todo implement loadRoleFromRoleVO
        throw new java.lang.UnsupportedOperationException("com.jrsystems.jrbase.role.loadRoleFromRoleVO(com.jrsystems.jrbase.role.vo.RoleVO) not yet implemented.");

        /* A typical implementation looks like this:
        com.jrsystems.jrbase.role.Role role = this.load(roleVO.getId());
        if (role == null)
        {
            role = com.jrsystems.jrbase.role.Role.Factory.newInstance();
        }
        return role;
        */
    }

    
    /**
     * @see com.jrsystems.jrbase.role.RoleDao#roleVOToEntity(com.jrsystems.jrbase.role.vo.RoleVO)
     */
    public com.jrsystems.jrbase.role.Role roleVOToEntity(com.jrsystems.jrbase.role.vo.RoleVO roleVO)
    {
        // @todo verify behavior of roleVOToEntity
        com.jrsystems.jrbase.role.Role entity = this.loadRoleFromRoleVO(roleVO);
        this.roleVOToEntity(roleVO, entity, true);
        return entity;
    }


    /**
     * @see com.jrsystems.jrbase.role.RoleDao#roleVOToEntity(com.jrsystems.jrbase.role.vo.RoleVO, com.jrsystems.jrbase.role.Role)
     */
    public void roleVOToEntity(
        com.jrsystems.jrbase.role.vo.RoleVO source,
        com.jrsystems.jrbase.role.Role target,
        boolean copyIfNull)
    {
        // @todo verify behavior of roleVOToEntity
        super.roleVOToEntity(source, target, copyIfNull);
    }

}